package o;

import android.content.Context;
import android.text.TextUtils;
import android.view.ViewGroup;
import androidx.fragment.app.Fragment;
import com.huawei.appgallery.wishbase.ui.fragment.BaseWishFragment;
import java.util.List;

public class ddm extends SomeFragmentStateAdapter {
    private Context ˎ;
    private dbz ˏ;
    private List<ddo> ॱ;

    public /* synthetic */ Fragment getItem(int i) {
        return ˋ(i);
    }

    public ddm(Context context, FragmentManager juVar, List<ddo> list) {
        super(juVar);
        this.ˎ = context;
        this.ॱ = list;
    }

    public void ˊ(dbz o_dbz) {
        this.ˏ = o_dbz;
    }

    public int getCount() {
        if (this.ॱ != null) {
            return this.ॱ.size();
        }
        return 0;
    }

    public CharSequence getPageTitle(int i) {
        if (CollectCheck.isEmpty(this.ॱ)) {
            return null;
        }
        if (isRTL()) {
            i = (getCount() - i) - 1;
        }
        ddo o_ddo = (ddo) this.ॱ.get(i);
        if (o_ddo == null || TextUtils.isEmpty(o_ddo.ॱ())) {
            return null;
        }
        return o_ddo.ॱ();
    }

    public void setPrimaryItem(ViewGroup viewGroup, int i, Object obj) {
        if (isRTL()) {
            i = (getCount() - i) - 1;
        }
        Fragment fragment = this.mCurrentPrimaryItem;
        super.setPrimaryItem(viewGroup, i, obj);
        Fragment fragment2 = (Fragment) obj;
        if (fragment2 != fragment) {
            if (fragment2 instanceof dca) {
                ((dca) fragment2).ˋ(i);
            }
            if (fragment instanceof dca) {
                ((dca) fragment).ʽˊ();
            }
        }
    }

    public BaseWishFragment ˋ(int i) {
        BaseWishFragment baseWishFragment;
        if (CollectCheck.isEmpty(this.ॱ)) {
            ddl.ˎ.ˊ("WishPageAdapter", "getItem, pageInfoList isEmpty");
            baseWishFragment = null;
        } else {
            ddo o_ddo = (ddo) this.ॱ.get(i);
            if (o_ddo != null) {
                Fragment ˎ = ˎ(o_ddo.ˎ());
                if (ˎ instanceof BaseWishFragment) {
                    baseWishFragment = (BaseWishFragment) ˎ;
                    baseWishFragment.ˎ(this.ˏ);
                }
            }
            baseWishFragment = null;
        }
        if (baseWishFragment != null) {
            return baseWishFragment;
        }
        baseWishFragment = new BaseWishFragment();
        ddl.ˎ.ˊ("WishPageAdapter", "getItem, ft == null, position: " + i);
        return baseWishFragment;
    }

    private Fragment ˎ(fjb o_fjb) {
        if (this.ˎ != null) {
            fiw ˋ = fiu.ˊ().ˋ(this.ˎ, o_fjb);
            if (ˋ != null) {
                fjm ˏ = fjm.ˏ(ˋ);
                if (ˏ != null) {
                    return ˏ.ˏ();
                }
            }
        }
        return null;
    }

    public Fragment ॱ() {
        return this.mCurrentPrimaryItem;
    }
}
